package at.main.gui;

import at.main.android.Graphics;
import at.main.util.AllImage;
import at.main.util.ManagerFont;

public class GameOverPage {

	public final String k_s0 = "Chơi lại";

	public final String k_s1 = "Về Menu";

	public final String k_s2 = "Thoát game";

	public int iSelectMenu = 0;

	public GameOverPage() {
		iSelectMenu = 0;
	}

	public void paint(Graphics g) {
		if (AllImage.img_lose != null) {
			g.drawImage(AllImage.img_lose, MyCanvas.iWidth / 2
					+ MyCanvas.iTranslateX - AllImage.img_lose.getWidth() / 2,
					MyCanvas.iHeight / 2 + MyCanvas.iTranslateY
							- AllImage.img_lose.getHeight() / 2, Graphics.TOP
							| Graphics.LEFT);
		}
		ManagerFont.drawString(g, k_s0, MyCanvas.iWidth / 2
				+ MyCanvas.iTranslateX, MyCanvas.iHeight / 2
				+ MyCanvas.iTranslateY + 20, 2, ((0-iSelectMenu)==0?1:2));
		ManagerFont.drawString(g, k_s1, MyCanvas.iWidth / 2
				+ MyCanvas.iTranslateX, MyCanvas.iHeight / 2
				+ MyCanvas.iTranslateY + 35, 2, ((1-iSelectMenu)==0?1:2));
		ManagerFont.drawString(g, k_s2, MyCanvas.iWidth / 2
				+ MyCanvas.iTranslateX, MyCanvas.iHeight / 2
				+ MyCanvas.iTranslateY + 50, 2, ((2-iSelectMenu)==0?1:2));

	}

	public void update() {
		// Up
		if (MyCanvas.keyHold[2]) {
			iSelectMenu--;
			if (iSelectMenu < 0)
				iSelectMenu = 2;
		}
		if (MyCanvas.keyHold[8]) {
			iSelectMenu++;
			if (iSelectMenu > 2)
				iSelectMenu = 0;
		}
		if (MyCanvas.keyHold[5]) {			
			switch (iSelectMenu) {
			case 0:	//choi lai				
				PlayGame.isTryAgain = true;
				PlayGame.isGameOver = false;
				MyCanvas.iCurrentPage = 4;				
				MyCanvas.clearInput();
				break;
			case 1: // Menu 
				PlayGame.isGameOver = false;
				MyCanvas.iCurrentPage = 3;
				MyCanvas.clearInput();
				break;
			case 2:	//exit
				MainMidlet.midlet.destroyApp(true);
				break;			
			}
		}
		MyCanvas.clearInput();
	}
}
